package StringC;

/**
 * Created with Intellij IDEA.
 * Description;
 * User:TQ02
 * Data:2024-03-02
 * Time:14:14
 * Text：得出字符串中含有最长的子字符串的逆序
 */
public class Text2 {
    public static String longestPalindrome(String s) {
        StringBuffer str=new StringBuffer();
        for(int i=s.length()-1;i>=0;i--){
            str.append(s.charAt(i));
        }
        int left=0,right=0;
        for(int i=0;i<s.length();i++){
            int k=0,j=i;
            while(k<str.length()){
                if(j<s.length() && s.charAt(j)==str.charAt(k)){
                    k++;
                    j++;
                }else{
                    if(j-i>right-left){
                        right=j;
                        left=i;
                    }
                    j=i;
                    k++;
                }
            }
            if(j-i>right-left){
                right=j;
                left=i;
            }
        }
        return s.substring(left,right);
    }

    public static void main(String[] args) {
        System.out.println(longestPalindrome("aacabdkacaa"));;
    }
}
